﻿<c:BaseControl x:Class="personalplaner.gui.stamm.views.SetPersonPensum"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:conv="clr-namespace:personalplaner.common.converters;assembly=personalplaner.common"
        xmlns:c="clr-namespace:personalplaner.common.controls;assembly=personalplaner.common"
        xmlns:p="clr-namespace:personalplaner.gui.Properties"
        xmlns:data="clr-namespace:personalplaner.business.stamm;assembly=personalplaner.business"
        xmlns:v="clr-namespace:personalplaner.gui.stamm.views"
        xmlns:vm="clr-namespace:personalplaner.common.mvvm.factory;assembly=personalplaner.common"
        xmlns:fac="clr-namespace:personalplaner.gui.stamm.viewmodels.factories"
        vm:ViewModelLoader.FactoryType="{x:Type fac:SetPersonPensumModelFactory}"
        Foreground="#E1000000">
    <!--Height="450"
        Width="650"
        ShowInTaskbar="False"
        WindowStartupLocation="CenterOwner"-->

    <Control.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <!--<ResourceDictionary Source="/personalplaner.common;component/resources/TabControlStyles.xaml"/>-->
                <ResourceDictionary Source="/personalplaner.common;component/resources/styles/WhiteStyleTemplates.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Control.Resources>
    
    <Control.Background>
        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="White" Offset="0"/>
                <GradientStop Color="White" Offset="0.6"/>
                <GradientStop Color="#FFEDEDED" Offset="1"/>
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
    </Control.Background>

    <Grid Margin="5,0,5,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <TextBlock Text="Arbeitspensum" FontSize="22" FontWeight="Thin" Foreground="#E1000000" Margin="50,-5,0,25"/>

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="200"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <GroupBox Grid.Column="1">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Border BorderBrush="Transparent" BorderThickness="1" Background="Transparent" Margin="2,2,2,20" Padding="5" >
                        <Grid>
                            <Grid.Resources>
                                <conv:BoolInvertConverter x:Key="BoolInvertConverter"/>
                            </Grid.Resources>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition MaxWidth="300"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition MaxWidth="300"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>

                            <CheckBox Grid.ColumnSpan="5" VerticalAlignment="Center" IsChecked="{Binding Model.IsKuendigung}">
                                <TextBlock Text="Kündigung (Arbeitsverhältis wird aufgelöst und endet am ...)"/>
                            </CheckBox>

                            <!--<Button Style="{StaticResource BoarderedButtonStyle}" Grid.Column="4" HorizontalAlignment="Right" Margin="5"
                        Command="{Binding ViewHistoryCommand}">
                    <Image Source="/personalplaner.gui;component/resources/images/History.png" Style="{StaticResource ButtonImageStyle}" Height="16" Margin="2"/>
                </Button>-->

                            <TextBlock Text="Arbeitspensum in %" Grid.Row="1"/>
                            <TextBox Grid.Row="1" Grid.Column="1" Margin="5" Text="{Binding Model.Prozent}" IsEnabled="{Binding Model.IsKuendigung, Converter={StaticResource BoolInvertConverter}}"/>

                            <TextBlock Text="Pensum von" Grid.Row="2"/>
                            <DatePicker Grid.Row="2" Grid.Column="1" Margin="5" SelectedDate="{Binding Model.Von, UpdateSourceTrigger=LostFocus}" IsEnabled="{Binding Model.IsKuendigung, Converter={StaticResource BoolInvertConverter}}"/>

                            <Image Source="/personalplaner.gui;component/resources/images/Info.png" Grid.Row="2" Grid.Column="2" Margin="0,0,50,0" Height="16">
                                <Image.ToolTip>
                                    <StackPanel>
                                        <TextBlock Text="Das Arbeitspensum- Ende kann nur auf ende Monat gesetzt werden."/>
                                        <TextBlock Text="Das Datum wird automatisch auf ende Monat gesetzt."/>
                                    </StackPanel>
                                </Image.ToolTip>
                            </Image>

                            <TextBlock Text="bis" Grid.Row="2" Grid.Column="3"/>
                            <DatePicker Grid.Row="2" Grid.Column="4" Margin="5" SelectedDate="{Binding Model.Bis, UpdateSourceTrigger=LostFocus}"/>

                            <Image Source="/personalplaner.gui;component/resources/images/Info.png" Grid.Row="2" Grid.Column="5" Margin="0,0,10,0" Height="16">
                                <Image.ToolTip>
                                    <StackPanel>
                                        <TextBlock Text="Das Arbeitspensum kann nur auf anfangs Monat gesetzt werden."/>
                                        <TextBlock Text="Das Datum wird automatisch auf anfang Monat gesetzt."/>
                                    </StackPanel>
                                </Image.ToolTip>
                            </Image>

                            <!--<Button Style="{StaticResource BoarderedButtonStyle}" Grid.Row="5" Grid.Column="4" HorizontalAlignment="Right" Margin="5,10,5,5"
                        Command="{Binding AddPensumCommand}">
                    <Image Source="/personalplaner.gui;component/resources/images/Add.png" Style="{StaticResource ButtonImageStyle}" Height="16" Margin="2"/>
                </Button>-->
                            <Button Grid.Row="5" Grid.Column="4" HorizontalAlignment="Right" Margin="5,20,5,5" Command="{Binding AddPensumCommand}">
                                <!--<TextBlock Text="{x:Static p:Resources.AddPensum}"/>-->
                                <TextBlock Text="{x:Static p:Resources.Save}"/>
                            </Button>
                        </Grid>
                    </Border>

                    <Grid Grid.Row="2">
                        <!--<Grid.ColumnDefinitions>
                            <ColumnDefinition MaxWidth="900"/>
                        </Grid.ColumnDefinitions>-->
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <!--<DataGrid Margin="2" ItemsSource="{Binding ArbeitsPensen}" SelectedItem="{Binding ActiveGridItem}" CanUserAddRows="False" 
                                  AutoGenerateColumns="False" CanUserSortColumns="False" VerticalScrollBarVisibility="Auto" 
                                  BorderBrush="Black" Background="Transparent">
                            <DataGrid.Resources>
                                <conv:DateTimeToIsoConverter x:Key="DateTimeToIsoConverter"/>
                            </DataGrid.Resources>
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Von" IsReadOnly="True" Binding="{Binding Von, Converter={StaticResource DateTimeToIsoConverter}}" MinWidth="90"/>
                                <DataGridTextColumn Header="Bis" IsReadOnly="True" Binding="{Binding Bis, Converter={StaticResource DateTimeToIsoConverter}}" MinWidth="90"/>
                                <DataGridTextColumn Header="Prozent" IsReadOnly="True" Binding="{Binding Prozent}" MinWidth="60"/>
                                <DataGridTextColumn Header="Status" IsReadOnly="True" Binding="{Binding StatusText}" Width="*"/>
                            </DataGrid.Columns>
                        </DataGrid>-->

                        <Grid Grid.IsSharedSizeScope="True" Margin="0,0,50,0">
                            <Grid.Resources>
                                <conv:DateTimeToIsoConverter x:Key="DateTimeToIsoConverter"/>

                                <DataTemplate DataType="{x:Type data:Pensum}">
                                    <Grid Margin="0,1,0,0">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="90" SharedSizeGroup="col2"/>
                                            <ColumnDefinition Width="90" SharedSizeGroup="col3"/>
                                            <ColumnDefinition Width="100" SharedSizeGroup="col4"/>
                                            <ColumnDefinition Width="100" SharedSizeGroup="col5"/>
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <TextBlock Text="{Binding Von, Converter={StaticResource DateTimeToIsoConverter}}" Grid.Column="0"/>
                                        <TextBlock Text="{Binding Bis, Converter={StaticResource DateTimeToIsoConverter}}" Grid.Column="1"/>
                                        <TextBlock Text="{Binding Prozent}" Grid.Column="2"/>
                                        <TextBlock Text="{Binding StatusText}" Grid.Column="3"/>

                                        <Button  HorizontalAlignment="Left" Grid.Column="5"  Margin="17,0,0,0" Cursor="Hand" Width="16" Height="16" Command="{Binding DataContext.DeletePensumCommand, RelativeSource={RelativeSource AncestorType={x:Type v:SetPersonPensum}}}" CommandParameter="{Binding}" ToolTip="{x:Static p:Resources.PensumEntfernen}">
                                            <Path Data="M 0,4 L 8,4" StrokeThickness="3" Stroke="Red" VerticalAlignment="Center" Height="8" HorizontalAlignment="Center"/>
                                        </Button>
                                        
                                    </Grid>
                                </DataTemplate>
                            </Grid.Resources>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="90" SharedSizeGroup="col2"/>
                                <ColumnDefinition Width="90" SharedSizeGroup="col3"/>
                                <ColumnDefinition Width="100" SharedSizeGroup="col4"/>
                                <ColumnDefinition Width="100" SharedSizeGroup="col5"/>
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>

                            <TextBlock Text="{x:Static p:Resources.Von}" FontWeight="Heavy" Grid.Column="0"/>
                            <TextBlock Text="{x:Static p:Resources.Bis}" FontWeight="Heavy" Grid.Column="1"/>
                            <TextBlock Text="{x:Static p:Resources.Prozent}" FontWeight="Heavy" Grid.Column="2"/>
                            <TextBlock Text="{x:Static p:Resources.Status}" FontWeight="Heavy" Grid.Column="3"/>

                            <Border BorderBrush="Black" BorderThickness="0,1,0,0" Background="Transparent" Grid.Row="1" Grid.ColumnSpan="7" Margin="0,5,0,0" SnapsToDevicePixels="True">
                                <ItemsControl ItemsSource="{Binding ArbeitsPensen}" Margin="0,10,0,0"/>
                            </Border>

                        </Grid>
                        
                    </Grid>
                </Grid>
            </GroupBox>
        </Grid>

        <StackPanel Orientation="Horizontal" Grid.Row="3" HorizontalAlignment="Right" Margin="0,20,40,20">
            <Button MinWidth="60" Margin="5" IsDefault="True" 
                    Command="{Binding OkCommand}">
                <TextBlock Text="OK"/>
            </Button>
            <Button MinWidth="60" Margin="5" IsCancel="True" 
                    Command="{Binding CancelCommand}">
                <TextBlock Text="Abbrechen"/>
            </Button>
        </StackPanel>
    </Grid>
</c:BaseControl>
